vixod = ''
sp = [str(i) for i in input().split()]
cifra = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
for i in sp:
    for k in range(10):
        if i == cifra[k]:
            vixod += str(k)
if int(vixod) < 99:
    print('Wrong input')
else:
    lst = []
    for i in range(100, 1000):
        for j in range(2, i):
            if i % j == 0:
                break
        else:
            lst.append(i)
    
    close_number = ''
    abs_diff = 999
    for el in lst:
        if abs(int(vixod) - el) < abs_diff:
            abs_diff, close_number = abs(int(vixod) - el), el
    print(close_number)